<div class="bjui-pageContent">
    <form action="${wwwroot}/admin/templateshell/save" id="editForm" data-toggle="validate" data-alertmsg="false" reloadNavtab="true">
        <input type="hidden" name="id" value="${(templateShell.id)!}" />
        <div class="pageFormContent" data-layout-h="0">
            <table class="table table-condensed table-hover" width="100%">
                <tbody>
                    <tr>
                        <td>
                            <label for="name" class="control-label x85">名称：</label>
                            <input type="text" name="name" id="name" value="${(templateShell.name)!}" data-rule="required" >
                        </td>
                        <td>
                            <label for="typeId" class="control-label x85">模板类型：</label>
                            <#--<@p.selector templateTypes 'id' 'typeName' templateShell 'typeId' 'typeName'/>-->
                            <input type="text" name="typeName" id="typeName" value="${(templateShell.typeName)!}" data-toggle="selectztree" size="18" data-tree="#j_select_tree2" readonly>
                            <input type="hidden" name="typeId" id="typeId" value="${(templateShell.typeId)!}">
                            <ul id="j_select_tree2" class="ztree hide" data-toggle="ztree" data-expand-all="true" data-check-enable="true" data-chk-style="radio" data-radio-type="all" data-on-check="S_NodeCheck" data-on-click="S_NodeClick">
                                <@p.tree typeTree/>
                            </ul>
                        </td>

                    </tr>
                    <tr>
                        <td colspan="2">
                            <label for="content" class="control-label x85">命令内容：</label>
                            <textarea  name="content" id="content" cols="70" rows="2" data-toggle="autoheight" data-rule="required">${(templateShell.content)!}</textarea>
                        </td>
                    </tr>
                </tbody>
            </table>
            <div style="height:20%; overflow:hidden;">
            <#include "include/handler.ftl">
            </div>
        </div>
    </form>
</div>
<div class="bjui-pageFooter" >
    <ul>
        <li><button type="button" class="btn btn-close" data-icon="close">取消</button></li>
        <li><button type="submit" class="btn btn-success" data-icon="save">保存</button></li>
    </ul>
</div>
<script type="text/javascript">
    //选择事件
    function S_NodeCheck(e, treeId, treeNode) {
        var zTree = $.fn.zTree.getZTreeObj(treeId),
                nodes = zTree.getCheckedNodes(true)
        var ids = '', names = ''

        for (var i = 0; i < nodes.length; i++) {
            ids   += ','+ nodes[i].id
            names += ','+ nodes[i].name
        }
        if (ids.length > 0) {
            ids = ids.substr(1), names = names.substr(1)
        }

        var $from = $('#'+ treeId).data('fromObj')

        if ($from && $from.length) $from.val(names)
        $('#typeId').val(ids);
    }
    //单击事件
    function S_NodeClick(event, treeId, treeNode) {
        var zTree = $.fn.zTree.getZTreeObj(treeId)

        zTree.checkNode(treeNode, !treeNode.checked, true, true)

        event.preventDefault()
    }
</script>